package com.ruoyi.labdata.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabLogotype;
import com.ruoyi.labdata.service.ILabLogotypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标记数据Controller
 * 
 * @author winner pan
 * @date 2022-02-14
 */
@RestController
@RequestMapping("/labdata/logotype")
public class LabLogotypeController extends BaseController {
	@Autowired
	private ILabLogotypeService labLogotypeService;

	/**
	 * 查询标记数据列表
	 */
	@PreAuthorize("@ss.hasPermi('labdata:logotype:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabLogotype labLogotype) {
		startPage();
		List<LabLogotype> list = labLogotypeService.selectLabLogotypeList(labLogotype);
		return getDataTable(list);
	}

	/**
	 * 导出标记数据列表
	 */
	// @PreAuthorize("@ss.hasPermi('labdata:logotype:export')")
	/*
	 * @Log(title = "标记数据", businessType = BusinessType.EXPORT)
	 * 
	 * @GetMapping("/export") public AjaxResult export(LabLogotype labLogotype)
	 * { List<LabLogotype> list =
	 * labLogotypeService.selectLabLogotypeList(labLogotype);
	 * ExcelUtil<LabLogotype> util = new
	 * ExcelUtil<LabLogotype>(LabLogotype.class); return util.exportExcel(list,
	 * "logotype"); }
	 */

	/**
	 * 获取标记数据详细信息
	 */
	@PreAuthorize("@ss.hasPermi('labdata:logotype:query')")
	@GetMapping(value = "/{logotypeId}")
	public AjaxResult getInfo(@PathVariable("logotypeId") Long logotypeId) {
		return AjaxResult.success(labLogotypeService.selectLabLogotypeById(logotypeId));
	}

	/**
	 * 新增标记数据
	 */
	@PreAuthorize("@ss.hasPermi('labdata:logotype:edit')")
	@Log(title = "标记数据", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabLogotype labLogotype) {
		return toAjax(labLogotypeService.insertLabLogotype(labLogotype));
	}

	/**
	 * 修改标记数据
	 */
	@PreAuthorize("@ss.hasPermi('labdata:logotype:edit')")
	@Log(title = "标记数据", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabLogotype labLogotype) {
		return toAjax(labLogotypeService.updateLabLogotype(labLogotype));
	}

	/**
	 * 删除标记数据
	 */
	@PreAuthorize("@ss.hasPermi('labdata:logotype:edit')")
	@Log(title = "标记数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logotypeIds}")
	public AjaxResult remove(@PathVariable Long[] logotypeIds) {
		return toAjax(labLogotypeService.deleteLabLogotypeByIds(logotypeIds));
	}
}
